<template>
  <el-form>
    <div class=" box">
      <el-form-item label="分组姓名">
        {{ info_modal }}
        <el-input v-model="info_modal.form_data.groupDescribe" />
      </el-form-item>
    </div>
    <div class="box1">
      <el-form-item class="box_btn">
        <el-button
          size="large"
          @click="handleNotEmit"
        >取消</el-button>
        <el-button
          size="large"
          @click="handleSubmit"
          type="primary"
          color="#1964d6"
        >保存信息</el-button>
      </el-form-item>
    </div>
  </el-form>
</template>

<script  setup>
import ProvinceSelect from "@/components/province-select/index.vue"
import UploadImage from "@/components/upload-image/index.vue"
import { GetStudentInfoApi, PlayerEntryApi } from "@/api/manage/institution"
import { ref } from "vue";
import { ElMessage } from "element-plus"

const emit = defineEmits(['sub'])
/**
 * 信息弹窗数据
 */
const info_modal = ref({
  form_data: {
    gender: "1"
  }
})
const handleRest = () => {
  info_modal.value.form_data = {
    gender: "1"
  }
}
/**
 * 获取学生信息
 */
const handleGetInfo = async (row) => {
  let res = await GetStudentInfoApi({
    studentId: row.studentId
  })
  if (res.success) {
    info_modal.value.form_data = res.entity;
  }

}

const handleNotEmit = () => {
  emit('sub', info_modal.value = false)
}

/**
 * 保存信息
 */
const handleSubmit = async () => {
  let res;
  res = await PlayerEntryApi(info_modal.value.form_data);
  if (res.success) {
    ElMessage.success(res.message);
    emit('sub', res)
  } else {
    ElMessage.error(res.message)
  }

}
defineExpose({
  handleGetInfo,
  handleRest
})
</script>

<style lang="scss" scoped>
.box {
  padding-bottom: 32px;
  padding-left: 18px;

  h3 {
    margin-bottom: 16px;
  }
}
.box1 {
  .box_btn {
    :deep(.el-form-item__content) {
      display: flex;
      justify-content: flex-end !important;
    }
  }
}
</style>